package com.shop.admin.controller.Admin;

import com.shop.entity.dto.AdminStyle.*;
import com.shop.entity.pojo.Style;
import com.shop.admin.service.CostService;
import com.shop.admin.service.StyleService;
import com.shop.utils.common.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/style")
public class AdminStyleController {

    @Autowired
    private StyleService styleService;
    @Autowired
    private CostService costService;

    @PostMapping("save_style")
    public Result saveOneStyle(@RequestBody AdminStyleSaveDto dto){
        log.info("后台管理-单独添加一个有关联的商品款式");
        return styleService.saveOneStyle(dto);
    }

    @PostMapping("update_get_style")
    public Result<Style> updateGetStyle(@RequestBody AdminStyleUpdateForGetDto dto){
        log.info("后台管理-修改商品款式数据回显");
        return styleService.updateGetStyle(dto);
    }

    @PostMapping("update_style")
    public Result updateStyle(@RequestBody AdminStyleUpdateDto dto){
        log.info("后台管理-修改商品款式");
        return styleService.updateStyle(dto);
    }

    @PostMapping("remove_style")
    public Result removeStyle(@RequestBody AdminStyleRemoveDto dto){
        log.info("后台管理-删除商品款式");
        return styleService.removeStyle(dto);
    }

    @PostMapping("get_style_list")
    public Result getStyleList(@RequestBody AdminStyleListDto dto){
        log.info("后台管理-商品款式列表");
        return styleService.getStyleList(dto);
    }

    @PostMapping("open_style")
    public Result openStyle(@RequestBody AdminStyleOpenDto dto){
        log.info("后台管理-恢复商品款式");
        return styleService.openStyle(dto);
    }

    @PostMapping("get_style_cost")
    public Result getStyleCost(@RequestBody AdminStyleCostDto dto){
        log.info("后台管理-商品款式相关价格");
        return costService.getStyleCostByPage(dto);
    }

    @PostMapping("pull_style")
    public Result pullStyle(@RequestBody AdminStylePullDto dto){
        log.info("后台管理-下架商品款式");
        return styleService.pullStyle(dto);
    }

    @PostMapping("put_style")
    public Result putStyle(@RequestBody AdminStylePutDto dto){
        log.info("后台管理-上架商品款式");
        return styleService.putStyle(dto);
    }

}
